package art.client;

import java.util.List;

import art.client.services.ArtService;
import art.client.services.ArtServiceAsync;
import art.client.services.UserService;
import art.client.services.UserServiceAsync;
import art.shared.entities.GenreShared;

import com.google.gwt.core.shared.GWT;

public class ClientUtils {
	
	public static UserServiceAsync getUserService() {
		UserServiceAsync userService = GWT.create(UserService.class);
		return userService;
	}
	
	public static ArtServiceAsync getArtService() {
		ArtServiceAsync artService = GWT.create(ArtService.class);
		return artService;
	}
	
	public static GenreShared getParentGenre(GenreShared genre, List<GenreShared> genres) {
		Long parentId = genre.getParentId();
		if (parentId == null) {
			return null;
		}
		for (GenreShared g :genres) {
			if (g.getId() == parentId) {
				return g;
			}
		}
		return null;
	}
}
